// ignore_for_file: prefer_typing_uninitialized_variables

/*
 * @Author: yangni
 * @Date: 2023-09-11 08:39:08
 * @LastEditors: yangni 920556271@qq.com
 * @LastEditTime: 2024-04-10 09:57:40
 * @Description: 消防详情页
 */
import 'dart:async';
import 'package:get/get.dart';
import 'package:yt_devops/pages/devices/device_tab/device_detail/base_detail_controller/base_detail_controller.dart';
import 'package:yt_devops/pages/devices/device_tab/device_detail/fire_fighting/air_cool_fire_detail/air_cool_fire_detail_model.dart';
import 'package:yt_devops/resources/str_res_keys.dart';
import 'package:yt_devops/services/device/device_sevices.dart';
import 'package:yt_devops/utils/socket/use_subscribe.dart';

class FireFightingDetailController extends BaseDetailController {
  String title = '';

  DeviceServices deviceServices = Get.find<DeviceServices>();

  /// scoket
  late Stream<Map<String, dynamic>> dataStream;
  List<FireFightingDetailModel> airInfos = [];
  UseSubsribe subsribe = UseSubsribe();

  /// 设备 id
  var deviceId;

  @override
  void onInit() {
    super.onInit();

    inheritArguments();
    generateDetailPage();
  }

  /// 继承参数
  void inheritArguments() {
    deviceId = Get.arguments['deviceId'];
    title = Get.arguments['deviceName'];
    connectStatus = Get.arguments['connectStatus'];
    dataStream = subsribe.start([deviceId], true).stream.asBroadcastStream();
  }

  /// 加载页面
  void generateDetailPage() async {
    renderedUiStructure();
  }

  /// 渲染页面UI结构
  void renderedUiStructure() {
    airInfos = [
      FireFightingDetailModel(
        ResKey.statusInfo.tr,
        FireFightingDetailModel.statusItems,
      ),
    ];

    update();
  }

  @override
  void onClose() {
    subsribe.closeListen();
  }
}
